Periodic Tasks: vwperiodic

In order to create useful reports, it is necessary to populate the Statistics module with meaningful records. In the simplest case it is possible to create statistic records manually by collating system information and inserting new statistic records with the required keys, dates, times and value. However it would not take long before someone forget to add the required records thus rendering the analysis incomplete.

The Periodic Tasks facility provides a framework in which tasks can be executed on a regular basis. Each task is a perl script generating one or more records for insertion into the estatistics table. At the heart of the framework is the vwperiodic program.

The vwperiodic script is run at regular intervals to generate statistical information. Its primary purpose is to invoke all the task scripts for a given time period (hourly, daily, weekly, monthly). The usage message for vwperiodic is:

Usage: vwperiodic [-q] [-l] [-d yyyy:mm:dd[:HH:MM:SS]] period [script...]

where:

-d yyyy:mm:dd[:HH:MM:SS]

is the date to use for periodic tasks.

-l

only run local scripts (local/etc/periodic)

-q

specifies quiet mode, i.e. do not output progress.

period

specifies the time period for which statistical data is generated. Allowable values:

  • daily
  • hourly
  • monthly
  • weekly

    Extra periods may be added, e.g. fortnightly, as required.

If one or more scripts are provided on the command line, only the named script(s) in the periodic directory will be executed. The default is to run all scripts.

The Unix task scheduler cron is used to execute vwperiodic at the required intervals. The crontab entries used to invoke vwperiodic are:

#

# Run periodic tasks

#

30 * * * * /home/vw/client/bin/vwrun vwperiodic hourly 2>&1 | /home/vw/client/bin/vwrun vwlogger -t "KE Vitalware Periodic Tasks Report" periodic

0 6 * * * /home/vw/client/bin/vwrun vwperiodic daily 2>&1 | /home/vw/client/bin/vwrun vwlogger -t "KE Vitalware Periodic Tasks Report" periodic

30 6 * * 0 /home/vw/client/bin/vwrun vwperiodic weekly 2>&1 | /home/vw/client/bin/vwrun vwlogger -t "KE Vitalware Periodic Tasks Report" periodic

0 7 1 * * /home/vw/client/bin/vwrun vwperiodic monthly 2>&1 | /home/vw/client/bin/vwrun vwlogger -t "KE Vitalware Periodic Tasks Report" periodic

The table below shows when each instance of vwperiodic is executed:

Command

Executed

vwperiodic hourly 30 minutes past the hour being analysed.
vwperiodic daily 6 hours past the day being analysed.
vwperiodic weekly 6 hours and 30 minutes past the week being analysed, on the Sunday morning.
vwperiodic monthly 7 hours past the month being analysed.

All output from running periodic tasks is sent to vwlogger which places the output into a file based on the current date (yyyy-mm-dd) in the logs/periodic directory. The log files provide a useful starting point if you suspect a problem with the execution of periodic tasks. As you can see, each task period is invoked after the time period for which it is generating statistics. The execution is delayed in order to allow any activities started in the task period to complete before the periodic tasks are run. It is also important to ensure that any system maintenance routines are not running while periodic tasks are executing, otherwise access to required tables may be denied.

When vwperiodic is invoked it looks for periodic tasks stored in either:

  • etc/periodic/period

    -OR-

  • local/etc/periodic/period

    where period is the argument supplied to vwperiodic (e.g. hourly). Each task is a perl script with a .pl (perl library) extension. If more than one task is found in the above directories, each task is executed sequentially in alphabetical order. Tasks in local/etc/periodic override scripts with the same name in etc/periodic.